package com.example.materialtest

import android.app.Activity
import android.media.Image
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.TextView

class MessageAdapter(activity: Activity, val resouerId: Int, data: List<message>) :ArrayAdapter<message>(activity,resouerId,data){
    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        val view=LayoutInflater.from(context).inflate(resouerId,parent,false)
        val messagetitle: TextView = view.findViewById(R.id.stitle)
        val messageimage_1: ImageView = view.findViewById(R.id.imageView)
        val messagepeople: TextView = view.findViewById(R.id.people)
        val messageimage_2: ImageView = view.findViewById(R.id.imageView2)
        val messagedate: TextView = view.findViewById(R.id.date)
        val messageinform: TextView = view.findViewById(R.id.inform)
        val message = getItem(position)
        if(message != null){
            messagetitle.text = message.title
            messageimage_1.setImageResource(message.imageId_1)
            messagepeople.text = message.people
            messageimage_2.setImageResource(message.imageId_2)
            messagedate.text = message.date
            messageinform.text = message.inform
        }
        return view
    }
}